<?php

function getLastComments($count = '5')
{
  global $wpdb;
  $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $count");
  if ( $comments ) {
    foreach ($comments as $comment) {
	echo '<li>' . sprintf(__('%1$s sur "%2$s"'), $comment->comment_author, '<a href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
	echo '</li>';
    }
  }
}

?>

    <div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar() ) : ?>

	<div class="sidebox">
		<div class="sidebox-title"><h2><?php _e('Search'); ?></h2></div>
		<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
		<div class="sidebox-content">
			<p style="margin: 5px" align="center">
			<input type="text" name="s" value="<?php echo wp_specialchars($s, 1); ?>" id="searchbox" />
			<input type="submit" value="<?php _e('Search'); ?>" />
			</p>
		</div>
		</form>
	</div>

        <?php if (function_exists('getLastComments')) { ?>
        <div class="sidebox-spacer"></div>
        <div class="sidebox">
        	<div class="sidebox-title"><h2><?php _e('Derniers Commentaires'); ?></h2></div>
        	<div class="sidebox-content"><ul><?php getLastComments() ?></ul></div>
        </div>
        <?php } ?>

        <?php if (function_exists('getTopPosts')) { ?>
        <div class="sidebox-spacer"></div>
        <div class="sidebox">
           <div class="sidebox-title"><h2><?php _e('Articles les + consult&eacute;s'); ?></h2></div>
      	   <div class="sidebox-content"><ul><?php 
        	if (function_exists('iri_StatPress_TopPosts')) {
        	   iri_StatPress_TopPosts(5, 'false');
        	   //getTopPosts()
        	}
      	   ?></ul></div>
        </div>
        <?php } ?>

        <?php if (function_exists('afdn_countdownTimer')) { ?>
        <div class="sidebox-spacer"></div>
        <div class="sidebox">
           <div class="sidebox-title"><h2>Compte &agrave; rebours</h2></div>
           <div class="sidebox-content">
              <ul>
                 <?php afdn_countdownTimer(); ?>
              </ul>
	   </div>
        </div>
        <?php } ?>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Cat&eacute;gories'); ?></h2></div>
            <div class="sidebox-content"><ul><?php wp_list_cats('sort_column=name'); ?></ul></div>
        </div>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Nuage de mots-clés'); ?></h2></div>
            <div class="sidebox-content"><?php wp_tag_cloud(''); ?></div>
        </div>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Nos amis'); ?></h2></div>
            <div class="sidebox-content"><ul><?php get_links(7, '<li>', '</li>', '', FALSE, 'name', FALSE); ?></ul></div>
        </div>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Nos photos'); ?></h2></div>
            <div class="sidebox-content"><ul><?php get_links(11, '<li>', '</li>', '', FALSE, 'name', FALSE); ?></ul></div>
        </div>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('On aime sur le net'); ?></h2></div>
            <div class="sidebox-content">
            <ul><?php get_links(6, '<li>', '</li>', '', FALSE, 'name', FALSE); ?></ul>
            </div>
        </div>

        <?php if (function_exists('wp_theme_switcher')) { ?>
        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Th&egrave;mes'); ?></h2></div>
            <div class="sidebox-content">
            <ul>
		<?php wp_theme_switcher('dropdown') ?>
	    </ul>
	    </div>
        </div>
        <?php } ?>

        <div class="sidebox-spacer"></div>
        <div class="sidebox">
            <div class="sidebox-title"><h2><?php _e('Archives'); ?></h2></div>
            <div class="sidebox-content"><ul><?php wp_get_archives('type=monthly'); ?></ul></div>
        </div>

<?php endif; ?>

</div>
